package com.briup.ch10;

import sun.applet.Main;

/**
 * @Author briup-adam
 * @Date 2023/10/27 下午5:52
 * @Description
 **/

public class DeadLock {
    public static void main(String[] args) {
        Object o1 = "月饼";
        Object o2 = "包子";
        Thread t1 = new Thread("海鹏") {
            @Override
            public void run() {
                for (int i = 0; i < 500000; i++) {
                    synchronized (o1) {
                            synchronized (o2) {
                            }

                    }
                }
            }
        };
        Thread t2 = new Thread("乔辉") {
            @Override
            public void run() {
                for (int i = 0; i < 500000; i++) {
                    synchronized (o2) {
                            synchronized (o1) {
                            }
                    }
                }
            }
        };
        t1.start();
        t2.start();
    }
}
